package com.hehao.consumer;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * 广播类型
 * @Author Damon
 * @Date 2024/7/30 10:00
 */
@Slf4j
@Component
public class FanoutCustomer {

    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(value = "fanoutQueue1"),
            exchange = @Exchange(value = "testFanoutExchange", type = ExchangeTypes.FANOUT)))
    public void listener1(String msg) {
        log.info("listener1-->接收消息【广播模式】：{}", msg);
    }

    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(value = "fanoutQueue2"),
            exchange = @Exchange(value = "testFanoutExchange", type = ExchangeTypes.FANOUT)))
    public void listener2(String msg) {
        log.info("listener2-->接收消息【广播模式】：{}", msg);
    }
}
